package com.foruo.demo.jdbc.service;

import com.foruo.demo.jdbc.dao.SimpleDao;
import com.foruo.demo.jdbc.datasource.ThreadLocalPool;
import com.foruo.demo.jdbc.entity.SimpleEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 模拟service
 * @author GaoYuan
 */
@Component
public class SimpleService {

    @Autowired
    ThreadLocalPool threadLocalPool;
    @Autowired
    SimpleDao simpleDao;

    public Object get() throws Exception{
        threadLocalPool.beginTransation();
        simpleDao.get();
        simpleDao.get();
        SimpleEntity simpleEntity = simpleDao.get();
        threadLocalPool.commit();
        return simpleEntity;
    }

}
